import 'package:flutter/material.dart';
import 'package:flutter_widget/widget/bg/ripple_background.dart';
import 'package:flutter_widget/widget/button/plain_button.dart';
import 'package:flutter_widget/widget/button/progress_button.dart';
import 'package:flutter_widget/widget/button/verification_code_button.dart';
import 'package:flutter_widget/widget/edit/edit_rounded.dart';
import 'package:flutter_widget/widget/edit/edit_rounded2.dart';
import 'package:flutter_widget/widget/page/one_page.dart';
import 'package:flutter_widget/widget/pop_ups/pop_up_util.dart';
import 'package:flutter_widget/widget/tab/equipment_specification_page.dart';

import 'my_animation.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
  void _incrementCounter() {
    ///item动画
    Navigator.push(
        context, MaterialPageRoute(builder: (_) => const MyAnimation()));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("收藏组件"),
      ),
      body: SingleChildScrollView(
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              const Text(
                'You have pushed the button this many times:',
              ),
              Text(
                '',
                style: Theme.of(context).textTheme.headline4,
              ),

              ///加载动画按钮
              ProgressButton(
                text: "登录",
                backColor: Colors.amber,
                onFinish: () {
                  print("zdh--------------finish ");
                },
              ),

              ///带水波纹效果
              RippleBackground(
                color: Colors.lightBlueAccent,
                child: Container(
                    alignment: Alignment.center,
                    width: 250,
                    height: 50,
                    child: const Text(
                      "点击",
                    )),
              ),
              //
              const EditRounded(
                hint: "请输入",
              ),

              const SizedBox(
                height: 10,
              ),

              const EditRounded2(
                hint: "请输入",
              ),

              const SizedBox(
                height: 10,
              ),
              const PlainButton(
                text: "保存",
                bgColor: Colors.amber,
                radius: 50,
                gradient: LinearGradient(
                    begin: Alignment.topLeft,
                    end: Alignment.topRight,
                    colors: [Colors.orange, Colors.yellow]),
              ),

              const SizedBox(
                height: 10,
              ),
              const VerificationCodeButton(),
              const SizedBox(
                height: 10,
              ),
              Container(
                color: Color(0xff0B0B0F),
                padding: EdgeInsets.all(50),
                child: const PlainButton(
                  width: 100,
                  height: 50,
                  text: "保存",
                  bgColor: Color(0xff20212A),
                  boxShadow: [
                    BoxShadow(
                      color: Color(0x1FC1C1D4),
                      offset: Offset(-2, -6),
                      blurRadius: 6,
                    ),
                  ],
                  radius: 50,
                  // gradient: LinearGradient(
                  //     begin: Alignment.topLeft,
                  //     end: Alignment.topRight,
                  //     colors: [Colors.orange, Colors.yellow]),
                ),
              ),

              ElevatedButton(
                  onPressed: () {
                    PopUpUtil.showTemperatureUnit(context,
                        leftText: "A", rightText: "B");
                  },
                  child: Text("pop")),

              const SizedBox(
                height: 20,
              ),
              ElevatedButton(
                  onPressed: () {
                    //路由跳转  固定写法  PageA 为目标页面类名
                    Navigator.of(context).push(MaterialPageRoute(
                        builder: (context) => const OnePage()));
                  },
                  child: Text("页面跳转")),
              const SizedBox(
                height: 20,
              ),
              ElevatedButton(
                  onPressed: () {
                    //路由跳转  固定写法  PageA 为目标页面类名
                    Navigator.of(context).push(MaterialPageRoute(
                        builder: (context) => EquipmentSpecificationPage()));
                  },
                  child: Text("页面跳转")),
              const SizedBox(
                height: 50,
              ),
            ],
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
